//
//  SRMeHeaderView.m
//  SportRing
//
//  Created by icelee on 14-11-1.
//  Copyright (c) 2014年 HotOne. All rights reserved.
//

#import "SRMeHeaderCell.h"
#import "SRMe+Cate.h"
#import <UIImageView+AFNetworking.h>
#import "UIView+Cat.h"

@implementation SRMeHeaderCellModel

- (id)initWithHeader:(UIImage *)headerImage
            userName:(NSString *)userName
            distance:(NSString*)distance
             kalorie:(NSString *)kalorie
               steps:(NSString *)steps
{
    self = [super init];
    if (self) {
        self.headerImage = headerImage;
        self.userName = userName;
        self.distance = distance;
        self.kalorie = kalorie;
        self.steps = steps;
    }
    return self;
}

@end

@interface SRMeHeaderCell()

@property (nonatomic, weak)IBOutlet UIImageView *headerImageView;
@property (nonatomic, weak)IBOutlet UILabel *userNameLabel;
@property (nonatomic, weak)IBOutlet UILabel *distanceLabel;
@property (nonatomic, weak)IBOutlet UILabel *kaloriLabel;
@property (nonatomic, weak)IBOutlet UILabel *stepsLabel;

@end

@implementation SRMeHeaderCell

- (void)awakeFromNib
{
    [super awakeFromNib];
    
}

- (void)setSRMeHeaderCellData:(SRMeHeaderCellModel *)model
{
    
    if ([[SRMe currentUser].gender integerValue] == SRGenderMale)
    {
        self.headerImageView.image = [UIImage imageNamed:@"select_gender_male"];
        
    }
    else
    {
        self.headerImageView.image = [UIImage imageNamed:@"select_gender_female"];
    }
    
    SRMe * me = [SRMe currentUser];
    if (me.headPhoto.length > 0)
    {
        [self.headerImageView setImageWithURL:[NSURL URLWithString:me.headPhoto]];
    }
    
    [self.headerImageView roundedCornerWithRadius:CGRectGetWidth(self.headerImageView.bounds) / 2
                                      borderColor:[UIColor lightGrayColor]
                                      borderWidth:0.5f];
    
    self.userNameLabel.text = model.userName;
    self.distanceLabel.text = model.distance;
    self.kaloriLabel.text = model.kalorie;
    self.stepsLabel.text = model.steps;
}

@end
